﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq.Mapping;
using System.ComponentModel;
using System.Data.Linq;

namespace Iridescent.Models
{
    [Table]
    public class Course : INotifyPropertyChanged, INotifyPropertyChanging
    {
        [Column(IsVersion = true)]
        private Binary _version;

        private int _id;
        [Column(IsPrimaryKey = true, IsDbGenerated = true)]
        public int Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    RaisePropertyChanging("Id");
                    _id = value;
                    RaisePropertyChanged("Id");
                }
            }
        }

        private string _name;
        [Column]
        public string Name
        {
            get { return _name; }
            set
            {
                if (_name != value)
                {
                    RaisePropertyChanging("Name");
                    _name = value;
                    RaisePropertyChanged("Name");
                }
            }
        }

        private DayOfWeek _day;
        [Column]
        public DayOfWeek Day
        {
            get { return _day; }
            set
            {
                if (_day != value)
                {
                    RaisePropertyChanging("Day");
                    _day = value;
                    RaisePropertyChanged("Day");
                }
            }
        }

        private DateTime _startTime;
        [Column]
        public DateTime StartTime
        {
            get { return _startTime; }
            set
            {
                if (_startTime != value)
                {
                    RaisePropertyChanging("StartTime");
                    _startTime = value;
                    RaisePropertyChanged("StartTime");
                }
            }
        }

        private DateTime _endTime;
        [Column]
        public DateTime EndTime
        {
            get { return _endTime; }
            set
            {
                if (_endTime != value)
                {
                    RaisePropertyChanging("EndTime");
                    _endTime = value;
                    RaisePropertyChanged("EndTime");
                }
            }
        }

        private string _location;
        [Column]
        public string Location
        {
            get { return _location; }
            set
            {
                if (_location != value)
                {
                    RaisePropertyChanging("Location");
                    _location = value;
                    RaisePropertyChanged("Location");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        private void RaisePropertyChanging(string propertyName)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
            }
        }
    }
}
